<!doctype html>
<html>
<head>
<title>分销设置</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<!-- Apple devices fullscreen -->
<meta name="apple-mobile-web-app-capable" content="yes">
<!-- Apple devices fullscreen -->
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
<link href="../css/main.css?v=12u234y" rel="stylesheet" type="text/css">
<link href="../css/page.css" rel="stylesheet" type="text/css">
<link href="../font/css/font-awesome.min.css" rel="stylesheet" />
<!--[if IE 7]>
  <link rel="stylesheet" href="../font/css/font-awesome-ie7.min.css">
<![endif]-->
<link href="../js/jquery-ui/jquery-ui.min.css" rel="stylesheet" type="text/css"/>
<link href="../js/perfect-scrollbar.min.css" rel="stylesheet" type="text/css"/>
<style type="text/css">html, body { overflow: visible;}</style>
<script type="text/javascript" src="../js/jquery.js"></script>
<script type="text/javascript" src="../js/jquery-ui/jquery-ui.min.js"></script>
<script type="text/javascript" src="../js/layer/layer.js"></script><!-- 弹窗js 参考文档 http://layer.layui.com/-->
<script type="text/javascript" src="../js/admin.js"></script>
<script type="text/javascript" src="../js/flexigrid.js"></script>
<script type="text/javascript" src="../js/jquery.validation.min.js"></script>
<script type="text/javascript" src="../js/perfect-scrollbar.min.js"></script>
<script type="text/javascript" src="../js/jquery.mousewheel.js"></script>
<script src="../js/myFormValidate.js"></script>
<script src="../js/myAjax2.js"></script>
<script src="../js/global.js"></script>
<script type="text/javascript">
function delfunc(obj){
	layer.confirm('确认删除？', {
		  btn: ['确定','取消'] //按钮
		}, function(){
			$.ajax({
				type : 'post',
				url : $(obj).attr('data-url'),
				data : {act:'del',del_id:$(obj).attr('data-id')},
				dataType : 'json',
				success : function(data){
					if(data==1){
						layer.msg('操作成功', {icon: 1});
						$(obj).parent().parent().parent().remove();
					}else{
						layer.msg(data, {icon: 2,time: 2000});
					}
				}
			})
		}, function(index){
			layer.close(index);
			return false;// 取消
		}
	);
}

function delAll(obj,name){
	var a = [];
	$('input[name*='+name+']').each(function(i,o){
		if($(o).is(':checked')){
			a.push($(o).val());
		}
	})
	if(a.length == 0){
		layer.alert('请选择删除项', {icon: 2});
		return;
	}
	layer.confirm('确认删除？', {btn: ['确定','取消'] }, function(){
			$.ajax({
				type : 'get',
				url : $(obj).attr('data-url'),
				data : {act:'del',del_id:a},
				dataType : 'json',
				success : function(data){
					if(data == 1){
						layer.msg('操作成功', {icon: 1});
						$('input[name*='+name+']').each(function(i,o){
							if($(o).is(':checked')){
								$(o).parent().parent().remove();
							}
						})
					}else{
						layer.msg(data, {icon: 2,time: 2000});
					}
					layer.closeAll();
				}
			})
		}, function(index){
			layer.close(index);
			return false;// 取消
		}
	);	
}

//表格列表全选反选
$(document).ready(function(){
	$('.hDivBox .sign').click(function(){
	    var sign = $('#flexigrid > table>tbody>tr');
	   if($(this).parent().hasClass('trSelected')){
	       sign.each(function(){
	           $(this).removeClass('trSelected');
	       });
	       $(this).parent().removeClass('trSelected');
	   }else{
	       sign.each(function(){
	           $(this).addClass('trSelected');
	       });
	       $(this).parent().addClass('trSelected');
	   }
	})
});

//获取选中项
function getSelected(){
	var selectobj = $('.trSelected');
	var selectval = [];
    if(selectobj.length > 0){
        selectobj.each(function(){
        	selectval.push($(this).attr('data-id'));
        });
    }
    return selectval;
}
</script>
</head>
<body style="background-color: #FFF; overflow: auto;">
<div id="append_parent"></div>
<div id="ajaxwaitid"></div>
<div class="page">
    <div class="fixed-bar">
        <div class="item-title">
            <div class="subject">
                <h3>分销设置</h3>
                <h5>平台分销选项设置</h5>
            </div>
            <ul class="tab-base nc-row">
                <li><a href="index.html"><span>商城信息</span></a></li>
                <li><a href="basic.html" ><span>基本设置</span></a></li>
                <li><a href="shopping.html"><span>购物流程</span></a></li>
                <li><a href="sms.html" ><span>短信设置</span></a></li>
                <li><a href="smtp.html" ><span>邮件设置</span></a></li>
                <li><a href="water.html" ><span>水印设置</span></a></li>
                <li><a href="distribut.html" class="current"><span>分销设置</span></a></li>
                <!--<li><a href="/index.php/admin/System/index/inc_type/wap.html" ><span>WAP设置</span></a></li>-->
                <!--<li><a href="/index.php/admin/System/index/inc_type/extend.html" ><span>扩展设置</span></a></li>-->
            </ul>
        </div>
    </div>
    <!-- 操作说明 -->
    <div class="explanation" id="explanation">
        <div class="title" id="checkZoom"><i class="fa fa-lightbulb-o"></i>
            <h4 title="提示相关设置操作时应注意的要点">操作提示</h4>
            <span id="explanationZoom" title="收起提示"></span> </div>
        <ul>
            <li>如果分销开关关闭，那么不会平台启用分销模块</li>
            <li>如果规则由平台设置，那么分销规则统一按平台设置的规则返利，否则按各商家自行设置的比例规则</li>
        </ul>
    </div>
    <form method="post" enctype="multipart/form-data" name="form1" id="handlepost" action="/index.php/admin/System/handle.html">
        <input type="hidden" name="inc_type" value="distribut">
        <div class="ncap-form-default">
            <dl class="row">
                <dt class="tit">分销开关</dt>
                <dd class="opt">
                    <div class="onoff">
                        <label for="switch1" class="cb-enable  selected">开启</label>
                        <label for="switch0" class="cb-disable ">关闭</label>
                        <input type="radio" onclick="$('#switch_on_off').show();"  id="switch1"  name="switch" value="1" checked="checked">
                        <input type="radio" onclick="$('#switch_on_off').hide();" id="switch0" name="switch" value="0"  >
                    </div>
                    <p class="notic">分销开关</p>
                </dd>
            </dl>
            <div id="switch_on_off" >
            <dl class="row">
                <dt class="tit">
                    <label>分销规则设置</label>
                </dt>
                <dd class="opt">
				    <input type="radio" name="distribut_set_by" value="0"  checked  >由平台设置  &nbsp;&nbsp;&nbsp;&nbsp;
                    <input type="radio" name="distribut_set_by" value="1" >由商家设置
                </dd>
            </dl>
            <dl class="row">
                <dt class="tit">
                    <label>一级分销商获佣百分比</label>
                </dt>
                <dd class="opt">
                    <input name="first_rate" id="distribut_first_rate" value="20" class="input-txt" type="text"  onpaste="this.value=this.value.replace(/[^\d]/g,'')" onkeyup="this.value=this.value.replace(/[^\d]/g,'')" >
                    <p class="notic">默认为0表示不获佣，最大为50</p>
                </dd>
            </dl>
            <dl class="row">
                <dt class="tit">
                    <label>二级分销商获佣百分比</label>
                </dt>
                <dd class="opt">
                    <input name="second_rate" id="distribut_second_rate" value="10" class="input-txt" type="text"  onpaste="this.value=this.value.replace(/[^\d]/g,'')" onkeyup="this.value=this.value.replace(/[^\d]/g,'')" >
                    <p class="notic">默认为0表示不获佣，最大为50</p>
                </dd>
            </dl>
            <dl class="row">
                <dt class="tit">
                    <label>三级分销商获佣百分比</label>
                </dt>
                <dd class="opt">
                    <input name="third_rate" id="distribut_third_rate" value="5" class="input-txt" type="text"  onpaste="this.value=this.value.replace(/[^\d]/g,'')" onkeyup="this.value=this.value.replace(/[^\d]/g,'')" >
                    <p class="notic">默认为0表示不获佣，最大为100</p>
                </dd>
            </dl>
            </div>
            <div class="bot">
                <input type="hidden" name="inc_type" value="distribut">
                <a href="JavaScript:void(0);" class="ncap-btn-big ncap-btn-green" onclick="formsubmit()">确认提交</a>
            </div>
        </div>
    </form>
</div>
<div id="goTop"> <a href="JavaScript:void(0);" id="btntop"><i class="fa fa-angle-up"></i></a><a href="JavaScript:void(0);" id="btnbottom"><i class="fa fa-angle-down"></i></a></div>
<script type="text/javascript">

function formsubmit(){
	var distribut_first_rate  = $.trim($('#distribut_first_rate').val());
	var distribut_second_rate = $.trim($('#distribut_second_rate').val());
	var distribut_third_rate  = $.trim($('#distribut_third_rate').val());		
	
	var rate = parseInt(distribut_first_rate) + parseInt(distribut_second_rate) + parseInt(distribut_third_rate);
	if(rate > 100)
	{
		layer.msg('三个分销商比例总和不得超过100%', {icon: 2,time: 2000});//alert('少年，邮箱不能为空！');		
		// alert('三个分销商比例总和不得超过100%');
		return false;
	}
	
	$('#handlepost').submit();
}

</script>
</body>
</html>